﻿@model SportsStore.WebUI.Models.CartIndexViewModel
@{
    ViewBag.Title = "Index";
}

<h2>Your cart</h2>
<table width="90%" align="center">
    <thead>
        <th align="center">Quantity</th>
        <th align="left">Item</th>
        <th align="right">Price</th>
        <th align="right">Subtotal</th>
    </thead>
    <tbody>
        @foreach (var line in Model.Cart.Lines)
        {
            <tr>
                <td align="center">@line.Quantity</td>
                <td align="left">@line.Product.Name</td>
                <td align="right">@line.Product.Price.ToString("c")</td>
                <td align="right">@((line.Quantity * line.Product.Price).ToString("c"))</td>
                <td>
                    @using (Html.BeginForm("RemoveFromCart", "Cart"))
                    {
                        @Html.HiddenFor(x=>x.ReturnUrl)
                        @Html.Hidden("ProductId", @line.Product.ProductId)
                        <input class="actionButtons" type="submit" value="Remove"/>
                    }
                </td>
            </tr>
        }
    </tbody>
    <tfoot>
    <tr>
        <td colspan="3" align="right">Total:</td>
        <td align="right">
            @Model.Cart.ComputeTotalValue().ToString("c")
        </td>
    </tr>
</table>
<p align="center" class="actionButtons">
    <a href="@Model.ReturnUrl">Continue shopping</a>
    @Html.ActionLink("Checkout now", "Checkout")
</p>
